import  os,xlrd,arcpy,arcgisscripting,sys

def excel2Class(excelPath):
    excelFile=xlrd.open_workbook(excelPath)
    sheet=excelFile.sheet_by_index(0)
    geometries =[]
    properties =[]
    for i in range(1,sheet.nrows):
        row = sheet.row_values(i)
        data = row[1]
        a_count = data.count("(")
        b_count = data.count(")")
        if a_count != b_count:
            continue
        polygons =[]
        property=[]
        j=0
        while j<len(data):
            if data[j].isdigit():
                start = j
                if data[j-1]=='-':
                    start = j-1
                end = data.index(')',start)
                polygons.append(data[int(start):int(end)])
                j=end
            else:j= j+1
        geometries.append(polygons)
        for col in range(0,sheet.ncols):
            property.append(row[col])
        properties.append(property)
    return geometries,properties


excelPath = 'C:\Users\lenovo\Desktop\\africa\data\origin\\Murdock_EA_2011_vkZ.xls'

geometries, properties = excel2Class(excelPath)
gp = arcgisscripting.create()
gp.OverwriteOutput = 1
outputShpPath = sys.argv[1]
outWorkspace = os.path.split(outputShpPath)[0]
shpName = os.path.split(outputShpPath)[-1]
spat_ref = "4326"
gp.CreateFeatureClass_management(outWorkspace, shpName, "POLYGON", "", "", "", spat_ref)
gp.addfield(outputShpPath, "NAME", "text", "", "", "100")
cur = gp.InsertCursor(outputShpPath)
newRow = cur.newRow()
for i in range(0,len(geometries)):
    arcpy.AddMessage('geometry:{0}'.format(i))
    geo = geometries[i]
    prop = properties[i]
    for j in range(0,len(geo)):
        newRow.NAME = prop[0]
        pnt = gp.CreateObject("point")
        array = gp.CreateObject("array")
        geo2 = geo[j]
        coors = geo2.split(',')
        for k in range(0,len(coors)):
            pos = coors[k].split(' ')
            if pos[0] == '':
                pos = pos[1:len(pos)]
            # arcpy.AddMessage('pos:{0}'.format(pos))
            pnt.X,pnt.Y =pos[0],pos[1]
            array.add(pnt)
        newRow.Shape = array
        cur.InsertRow(newRow)
del cur, newRow